home *** CD-ROM | disk | FTP | other *** search
- Path: news.cstone.net!usenet
- From: scottv@cstone.net (Scott)
- Newsgroups: comp.lang.c++
- Subject: Subclassing a Window - Getting a Pointer to a WNDPROC Class Method? Valid?
- Date: 26 Feb 1996 02:50:03 GMT
- Organization: Cornerstone Networks - Pure Internet!
- Message-ID: <4gr74r$fj8@dot.cstone.net>
- NNTP-Posting-Host: dialin11.cstone.net
- Mime-Version: 1.0
- Content-Type: Text/Plain; charset=US-ASCII
- X-Newsreader: WinVN 0.99.7
-
- I'm writing a class definition that will need to subclass a window inorder to
- monitor for such messages as Size, Destroy and others. Is it valid C++
- syntax to attempt to get the pointer to a method that is a WNDPROC routine?
- If so, how do I obtain it (I get an invalid cast from long to class member
- pointer). If this is not ligitimate C++ syntax, how can I attach an instance
- of the class to the subclass WNDPROC. Here is an example to make it clearer.
-
- class CThing
- {
- public:
- long m_pOriginalWndProc;
- HWND m_hWnd;
- public:
- void SubclassWindow();
- void UnSubclassWindow();
- LRESULT WNDPROC SubclassWndProc(....);
- };
-
- void CThing::SubclassWindow()
- {
- m_pOriginalWndProc=SetWindowLong(m_hWnd,GWL_WNDPROC,???????);
- };
-
- void CThing::UnSubclassWindow()
- {
- SetWindowLong(m_hWnd,GWL_WNDPROC,m_pOriginalWndProc);
- };
-
- LRESULT WNDPROC CThing::SubclasWndProc(....)
- {
- switch (Message)
- {
- case WM_SIZE:
- break;
- }
- CallWndProc(m_pOriginalWndProc,....);
- };
-
- The m_hWnd is a handle to a window that I need to monitor for these
- events. I can use a normal (not a method of the class) routine to subclass
- the window, but I need to attach the class object to the subclassing routine
- inorder to trigger events within the object - the class will have many
- instances at any given time. If I can't use the pointer to the method, what
- would be a clean method of communicating the pointer to the class object to
- the subclassing routine? If anyone could possibly help, I would appreciate
- it - please email me (I don't get into the news groups enough) directly.
- Thanks in advance...this should be a simple question of whether the C++
- syntax is valid - but I can't find documentation online with VC++ 4.0.
-
- Sincerely,
- N. Scott Vann
- Motivational Concepts, Inc.
- Software Engineer/Multimedia Training Systems
-
- P.S. - In a nut shell, with C++, can you obtain a pointer to an objects
- method routine? This is to be used for subclassing a window ... if so, what
- is the proper syntax?
-
- Thanks again...
-
-